//
//  NSString+Date.m
//  lifestyle
//
//  Created by wd on 15/8/21.
//  Copyright (c) 2015年 Wei Chuang Le ,Ltd. All rights reserved.
//

#import "NSString+Date.h"

@implementation NSString (Date)

+ (NSString *)stringWithNowDateType:(dateType)dateType
{
    NSString *type = dateType == dateType_12 ? @"hh" :@"HH";
    NSDateFormatter *df = [[NSDateFormatter alloc]init];
    [df setDateFormat:[NSString stringWithFormat:@"yyyy-MM-dd-%@-mm-ss",type]]; // HH:24小时制 hh:12小时制
    
    NSTimeInterval timeZoneOffset = [[NSTimeZone systemTimeZone] secondsFromGMT];
    NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0];
    [date dateByAddingTimeInterval:timeZoneOffset];
    
    NSString *time = [df stringFromDate:date];
    return time;
}

+ (NSString *)stringWithNowDateWithoutSecond:(dateType)dateType
{
    NSString *type = dateType == dateType_12 ? @"hh" :@"HH";
    NSDateFormatter *df = [[NSDateFormatter alloc]init];
    [df setDateFormat:[NSString stringWithFormat:@"yyyyMMdd%@mm",type]]; // HH:24小时制 hh:12小时制
    
    NSTimeInterval timeZoneOffset = [[NSTimeZone systemTimeZone] secondsFromGMT];
    NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0];
    [date dateByAddingTimeInterval:timeZoneOffset];
    
    NSString *time = [df stringFromDate:date];
    return time;
}
@end
